<script setup lang="ts">
import type { obsDataType } from "#/utils/obs"
import { type PropType } from 'vue';
import { downloadFile } from "#/utils/obs"


defineOptions({ name: 'Download' })
const props = defineProps({
  obs: {
    type: Object as PropType<obsDataType>,
    default: { Key: '' }
  },
  downloadName: {
    type: String as PropType<string>,
    default: '下载'
  },
  blobConfig: {
    type: Object,
    default: {}
  },
  link: {
    type: Boolean,
    default: false
  },
  type: {
    type: String,
    default: 'default'
  }
})

const download = () => {
  if (!props.obs.Key) return
  downloadFile(props.obs, props.blobConfig)
}

</script>
<template>
  <ElButton :link="link" :type="type" v-bind="$props" @click="download">{{ downloadName }}</ElButton>
</template>
